package com.novel2comic.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
	@Value("${novel2comic.allowOrigins:*}")
	private String allowOrigins;
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**")
			.allowedOrigins(allowOrigins.split(","))
			.allowedMethods("GET","POST","PUT","DELETE","OPTIONS")
			.allowCredentials(false)
			.maxAge(3600);
	}
}
